import { createSlice, PayloadAction } from "@reduxjs/toolkit";

export const otherSlice = createSlice({
  name: "other",
  initialState: {
    name: "我是张三",
    age: 15,
  },
  reducers: {
    changeName: (state) => {
      state.name = "我是李四";
    },
    backName: (state) => {
      state.name = "我是张三";
    },
    addAge: (state, action: PayloadAction<number>) => {
      state.age += action.payload;
    },
  },
});

export const { changeName, backName, addAge } = otherSlice.actions;
export default otherSlice.reducer;
